package com.hjq.mallsearch.controller;

import com.hjq.mallsearch.service.ResultSearchService;
import com.hjq.mallsearch.vo.SearchParamVO;
import com.hjq.mallsearch.vo.SearchResponseVO;
import org.apache.http.HttpRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * @auther HJQ
 */
@Controller
public class searchController {
    @Autowired
    ResultSearchService resultSearchService;
    @RequestMapping("/list.html")
    public  String searchCategory(SearchParamVO searchParam, Model model, HttpServletRequest request){
        String queryString = request.getQueryString();
        searchParam.set_queryString(queryString);
        //将检索的结果放在model中
        SearchResponseVO responseVO = resultSearchService.search(searchParam);
        model.addAttribute("result",responseVO);

        return  "list";
    }
}
